package org.kabeja.parser.entities;

import org.kabeja.dxf.entity.DXFEntity;
import org.kabeja.dxf.entity.DXFRay;
import org.kabeja.parser.DXFValue;

/**
 * @author shutao
 * @since 2022/4/25 11:44
 */
public class DXFRayHandler extends AbstractEntityHandler {
    protected DXFRay ray;

    public DXFRayHandler() {
    }

    @Override
    public String getDXFEntityName() {
        return "RAY";
    }

    @Override
    public void endDXFEntity() {
    }

    @Override
    public DXFEntity getDXFEntity() {
        return this.ray;
    }

    @Override
    public boolean isFollowSequence() {
        return false;
    }

    @Override
    public void parseGroup(int var1, DXFValue var2) {
        switch(var1) {
            case 10:
                this.ray.getBasePoint().setX(var2.getDoubleValue());
                break;
            case 11:
                this.ray.getDirection().setX(var2.getDoubleValue());
                break;
            case 20:
                this.ray.getBasePoint().setY(var2.getDoubleValue());
                break;
            case 21:
                this.ray.getDirection().setY(var2.getDoubleValue());
                break;
            case 30:
                this.ray.getBasePoint().setY(var2.getDoubleValue());
                break;
            case 31:
                this.ray.getDirection().setZ(var2.getDoubleValue());
                break;
            default:
                super.parseCommonProperty(var1, var2, this.ray);
        }

    }

    @Override
    public void parseObject(int var1, DXFValue var2, int type) {
        super.parseObjectProperty(var1, var2, type, this.ray);
    }

    @Override
    public void startDXFEntity() {
        this.ray = new DXFRay();
    }
}
